import requests

# url = 'http://httpbin.org/post'
# with open('testday5.txt', 'rb') as fp:
#     file = {'file':fp}
#     r = requests.post(url, files=file)
#     print(r.text)


# url = 'http://httpbin.org/post'
# file = {'file':open('testday5.txt', 'rb')}
# r = requests.post(url, files=file)
# print(r.text)


s = requests.Session()
# 登陆
data = 'username=admin&password=admin123&verifycode=0000'
headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
r = s.post('http://localhost:8081/WoniuSales/user/login', data=data, headers=headers)
print(r.text)

# 批次管理-上传批次文件
upload_file = {
    'batchfile': ('GB20181010.xls', open(r'e:\Workspace\08-课件\1a.txt-讲课\直播_高级研发班_接口测试\销售出库单-20181010-Test.xls', 'rb'))}
upload_url = 'http://localhost:8081/WoniuSales/goods/upload'
data = {'batchname': 'GB20181010'}
r = s.post(upload_url, data=data, files=upload_file)
print(r.text)
